$(document).ready(function(){
$("#getNextQuestion").click(function(){
 $.get("http://localhost:8080/tripplanner/questions?countryId=111",function(data,status){
    $("#question_content").text("Please rate this Attraction from 1 to 10: " + data.bestCandidateToReplace.name);
    $("#voteButton").data('attractionQuestionId', data.id);
    $("#voteButton").data('attractionToVote', data.bestCandidateToReplace);
  });
});
});

$(document).ready(function(){
$("#voteButton").click(function(){
	var postText = {"id":1,
			"attractionQuestionId":$(this).data('attractionQuestionId'),
			"voteValue": document.getElementById("votingValue").value,
			"attraction": $(this).data('attractionToVote')
			};
	$.post("http://localhost:8080/tripplanner/questions",
			JSON.stringify(postText),
			 function(data,status){
	    		alert("Data: " + data + "\nStatus: " + status);
	  		}
		);
});	
});

$(document).ready(function(){
	$("#planRoute").click(function(){
		var dosage= {"id":1,
				"familyPercentage":document.getElementById("family").value,
				"nightLifePercentage":document.getElementById("night").value,
				"trekkingPercentage":document.getElementById("trekking").value,
				"extremePercentage":document.getElementById("extreme").value,
				"culturePercentage":document.getElementById("culture").value
			};
		$.post("http://localhost:8080/tripplanner/planroute?countryId=111&travelTime=" + document.getElementById("travelDays").value,
				JSON.stringify(dosage),
				function(data,status){
				var cityList = "<ol>";
				var attractionList="<ol>";
					for(var i=0; i<data.cities.length; i++){
						cityList+= "<li>" + data.cities[i].name + "</li>";
					}
					cityList += "</ol>";
				 $("#cities").html(cityList);
				 
				 for(var j=0; j<data.attractions.length; j++){
					 attractionList+=  "<li>" + data.attractions[j].name + "</li>";
				 }
				 attractionList += "</ol>";
				 $("#attractions").html(attractionList);
				}
		);
				
	});
});
	